<template>
    <view class="container data-v-cba957aa" v-if="info.id">
        <navigator class="data-v-cba957aa" url="/pages/resale/index">
            <view class="float-btn data-v-cba957aa">
                <image class="data-v-cba957aa" src="https://img121.7dun.com/yuanqimali/resaledetail/zhuanshoujilu.png"></image>
            </view>
        </navigator>
        <view class="data-v-cba957aa" style="height: 68rpx"></view>
        <view class="card-c data-v-cba957aa">
            <view :class="['status-c', 'data-v-cba957aa', info.union_status]">{{ info.union_status_text }}</view>
            <view class="user-c data-v-cba957aa">
                <image class="headimg data-v-cba957aa" mode="widthFix" :src="user.headimg"></image>
                <view class="middle data-v-cba957aa">
                    <view class="name data-v-cba957aa">
                        <teext @__l="__l" class="data-v-cba957aa" vueId="3c1e1449-1" :vueSlots="['default']">{{ user && user.name }}</teext>
                        <teext @__l="__l" class="data-v-cba957aa" vueId="3c1e1449-2" :vueSlots="['default']">正在出售以下商品</teext>
                    </view>
                    <view class="last-time data-v-cba957aa">{{ $root.g0 + '发起' }}</view>
                </view>
            </view>
            <view class="product-c data-v-cba957aa">
                <block v-if="$root.g1 === 1">
                    <image class="thumb data-v-cba957aa" mode="aspectFit" :src="sku.thumb"></image>
                    <view class="title data-v-cba957aa">{{ sku.title + ' x' + sku.total }}</view>
                </block>
                <view class="sku-list data-v-cba957aa" v-else>
                    <view class="item data-v-cba957aa" v-for="(sku, __i0__) in skus" :key="__i0__">
                        <image class="thumb data-v-cba957aa" mode="aspectFit" :src="sku.thumb"></image>

                        <view class="title data-v-cba957aa">{{ sku.title + ' x' + sku.total }}</view>
                    </view>
                </view>
                <view class="data-v-cba957aa">
                    <view class="price-c data-v-cba957aa">
                        <label class="_span data-v-cba957aa" style="margin-right: 10px">转让价</label>
                        <price-display @__l="__l" class="data-v-cba957aa" :info="info" vueId="3c1e1449-3"></price-display>
                    </view>
                </view>
                <block v-if="info.union_status === 'pending'">
                    <block v-if="!info.is_creator">
                        <button @tap="__e" class="bottom-btnsx buy-btn data-v-cba957aa" :data-event-opts="[['tap', [['buy', ['$event']]]]]" :plain="true">
                            <image class="data-v-cba957aa" src="https://img121.7dun.com/yuanqimali/resaledetail/lijishouxia.png"></image>
                        </button>
                        <view class="tips data-v-cba957aa">转售商品一经售出，不可退换</view>
                    </block>
                    <view class="button-group data-v-cba957aa" v-else>
                        <button class="bottom-btnshaoyou data-v-cba957aa" openType="share" :plain="true">转发给好友</button>
                        <button @tap="__e" class="bottom-btns data-v-cba957aa" :data-event-opts="[['tap', [['cancel', ['$event']]]]]" :plain="true">取消挂售</button>
                    </view>
                </block>
                <block v-else>
                    <button class="quxiao-btn data-v-cba957aa" :plain="true" v-if="info.union_status === 'closed'">转售取消</button>
                    <block v-else>
                        <view class="buyer-c data-v-cba957aa" v-if="info.union_status === 'completed'">
                            已由
                            <image class="buyer-headimg data-v-cba957aa" mode="aspectFit" :src="info.buyer.headimg"></image>
                            {{ '' + info.buyer.name + ' 完成购买' }}
                        </view>
                    </block>
                </block>
            </view>
        </view>
    </view>
</template>

<script>
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/resale/detail'],
    {
        3616: function (t, e, n) {
            'use strict';

            (function (t) {
                var i = n('4ea4');
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var o = i(n('9523'));
                var a = i(n('82c0'));
                function r(t, e) {
                    var n = Object.keys(t);
                    if (Object.getOwnPropertySymbols) {
                        var i = Object.getOwnPropertySymbols(t);
                        if (e) {
                            i = i.filter(function (e) {
                                return Object.getOwnPropertyDescriptor(t, e).enumerable;
                            });
                        }
                        n.push.apply(n, i);
                    }
                    return n;
                }
                function s(t) {
                    for (var e = 1; e < arguments.length; e++) {
                        if (null != arguments[e]) {
                            var n = arguments[e];
                        } else {
                            var n = {};
                        }
                        if (e % 2) {
                            r(Object(n), true).forEach(function (e) {
                                (0, o.default)(t, e, n[e]);
                            });
                        } else {
                            Object.getOwnPropertyDescriptors
                                ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n))
                                : r(Object(n)).forEach(function (e) {
                                      Object.defineProperty(t, e, Object.getOwnPropertyDescriptor(n, e));
                                  });
                        }
                    }
                    return t;
                }
                var c = {
                    components: {},
                    data: function () {
                        return {
                            uuid: '',
                            info: {
                                user: {}
                            },
                            user: {}
                        };
                    },
                    filters: {},
                    computed: {
                        skus: function () {
                            return this.info.package_skus || [];
                        },
                        sku: function () {
                            return (this.info.package_skus && this.info.package_skus[0]) || {};
                        },
                        share: function () {
                            return {
                                title: this.info.user.name + '向你转售了一个商品，快来看看吧~'
                            };
                        },
                        detailImages: function () {
                            return this.sku.detail_images;
                        }
                    },
                    onLoad: function (t) {
                        this.uuid = t.uuid;
                    },
                    onShow: function () {
                        this.initData();
                    },
                    methods: {
                        initData: function () {
                            var that = this;
                            this.$http('/asset/resales/'.concat(this.uuid)).then(function (e) {
                                that.info = e.data.info;
                                that.user = e.data.info.user;
                            });
                        },
                        buy: function () {
                            var that = this;
                            t.showLoading({
                                title: '购买中'
                            });
                            this.$http('/asset/resale-order/confirm', 'POST', {
                                resale_id: this.info.id
                            }).then(function (n) {
                                t.hideLoading();
                                var i = n.data;
                                n.data.is_need_pay
                                    ? a.default.pay(
                                          s(
                                              s({}, i),
                                              {},
                                              {
                                                  success: function () {
                                                      that.initData();
                                                      t.showToast({
                                                          title: '购买成功，即将跳转~',
                                                          icon: 'none'
                                                      });
                                                      setTimeout(function (e) {
                                                          t.redirectTo({
                                                              url: '/pages/myBox/index'
                                                          });
                                                      }, 1500);
                                                  },
                                                  fail: function () {
                                                      t.showToast({
                                                          title: '支付失败',
                                                          icon: 'none'
                                                      });
                                                      that.$http('/orders/'.concat(i.order.uuid), 'PUT', {
                                                          type: 'close_and_delete'
                                                      });
                                                  }
                                              }
                                          )
                                      )
                                    : (t.showToast({
                                          title: '购买成功~',
                                          icon: 'none'
                                      }),
                                      that.initData());
                            });
                        },
                        cancel: function () {
                            var that = this;
                            t.showModal({
                                title: '提示',
                                content: '确认要取消此转售吗?',
                                success: function (n) {
                                    if (n.confirm) {
                                        t.showLoading({
                                            title: '取消中'
                                        });
                                        that.$http('/asset/resales/'.concat(that.uuid), 'PUT', {
                                            type: 'close'
                                        }).then(function (n) {
                                            t.hideLoading();
                                            t.showToast({
                                                title: '取消成功~',
                                                icon: 'none'
                                            });
                                            that.initData();
                                        });
                                    }
                                }
                            });
                        },
                        toResaleIndex: function () {
                            t.navigateTo({
                                url: '/pages/resale/index'
                            });
                        }
                    }
                };
                e.default = c;
            }.call(this, n('543d').default));
        },
        '519f': function (t, e, n) {
            'use strict';

            n.d(e, 'b', function () {
                return o;
            });
            n.d(e, 'c', function () {
                return a;
            });
            n.d(e, 'a', function () {
                return i;
            });
            var i = {
                PriceDisplay: function () {
                    return n.e('components/PriceDisplay/PriceDisplay').then(n.bind(null, '6b05'));
                }
            };
            var o = function () {
                this.$createElement;
                var t = (this._self._c, this.info.id ? this.$tool.showShortTime(this.info.created_at) : null);
                if (this.info.id) {
                    var e = this.skus.length;
                } else {
                    var e = null;
                }
                this.setData(
                    Object.assign(
                        {},
                        {
                            $root: {
                                g0: t,
                                g1: e
                            }
                        }
                    )
                );
            };
            var a = [];
        },
        7884: function (t, e, n) {
            'use strict';

            var i = n('9cbe');
            n.n(i).a;
        },
        '81d5': function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('519f');
            var o = n('f671');
            for (var a in o) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return o[t];
                        });
                    })(a);
                }
            }
            n('ea02');
            n('7884');
            var r = n('f0c5');
            var s = Object(r.a)(o.default, i.b, i.c, false, null, 'cba957aa', null, false, i.a, void 0);
            e.default = s.exports;
        },
        '9c32': function (t, e, n) {
            'use strict';

            (function (t, e) {
                var i = n('4ea4');
                n('18ba');
                i(n('66fd'));
                var o = i(n('81d5'));
                t.__webpack_require_UNI_MP_PLUGIN__ = n;
                e(o.default);
            }.call(this, n('bc2e').default, n('543d').createPage));
        },
        '9cbe': function (t, e, n) {},
        '9dc4': function (t, e, n) {},
        ea02: function (t, e, n) {
            'use strict';

            var i = n('9dc4');
            n.n(i).a;
        },
        f671: function (t, e, n) {
            'use strict';

            n.r(e);
            var i = n('3616');
            var o = n.n(i);
            for (var a in i) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return i[t];
                        });
                    })(a);
                }
            }
            e.default = o.a;
        }
    },
    [['9c32', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './detail.css';
</style>
